%module memory

%{

#include <stdlib.h>
#include <string.h>

void *
void_ptr(size_t pos)
{
	return (void *)pos;
}

unsigned char
peek(void *memory, size_t pos)
{
	unsigned char *m = memory;
	return m[pos];
}

unsigned char
poke(void *memory, size_t pos, unsigned char value)
{
	char *m = memory;
	m[pos] = value;
	return m[pos];
}

%}

void *calloc(size_t, size_t);
void *malloc(size_t);
void free(void*);
void *memset(void*, int, size_t);
void *memcpy(void*, const void*, size_t);

void *void_ptr(size_t);
unsigned char peek(void*, size_t);
unsigned char poke(void*, size_t, char);
